﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Collections.Generic;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for ProductionOrder.xaml
    /// </summary>
    public partial class TVRPOS:UIVRP
    {

        public TVRPOS()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VVRPOS(); 
            this.DataContext = MV;
            InitializeComponent();
         }

        public override void QueryCommand(object sender, RoutedEventArgs e)
        {
            dwData = TBMain.NewRow();
            dwData["VRPAUFKRS"] = KRS.Trim();
            dwData["VRPAUFLFD"] = LFD.Trim();
            if (LFD == "000000")
            {
                dwData["VRPAUFLFD"] = "";
            }
            else
            {
                dwData["VRPAUFLFD"] = KUNDNR;
            }
            if (KUNDNR == "00000000")
            {
                dwData["VRPARTKUNDNR"] = "";
            }
            else
            {
                dwData["VRPARTKUNDNR"] = KUNDNR;
            }
            if (IsPaid)
            {
                dwData["VRPBONKZ"] = " AND (VRPBONKZ='J' OR VRPBONKZ=' ')";
            }
            else
            {
                dwData["VRPBONKZ"] = " AND VRPBONKZ=' ' ";
            }
            SResult = ((VVRPOS)MV).QueryVRPOS(dwData, 7);
            MergeData(SResult, true, true);
            base.QueryCommand(sender, e);
        }
        
        public override void LOADBYVKP(string vkp)
        {
            dwData = TBMain.NewRow();
            PM["VKP"] = vkp; 
            SResult = ((VVRPOS)MV).LOADBYVKK(PM);
            MergeData(SResult, true, true);  
        }
        
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {

        } 
        
    }
}
